#include<bits/stdc++.h>
using namespace std;
template <typename T>void read(T &x){
    int f=1;x=0;char c=getchar();
    for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    x*=f;
}
const int maxn=1e6+5;
int n,T,m,L,V,v0[maxn],a[maxn],pl[maxn],d[maxn],isv[maxn],sum[maxn],c[maxn];
int l[maxn],r[maxn];
void add(int x,int val){
    for(;x<=L;x+=x&-x)c[x]+=val;
}

int ask(int x){
    int ans=0;
    for(;x;x-=x&-x)ans+=c[x];
    return ans;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    read(T);
    while(T--){
        read(n);read(m);read(L);read(V);
        memset(v0,0,sizeof(v0));
        memset(a,0,sizeof(a));
        memset(l,0,sizeof(l));
        memset(r,0,sizeof(r));
        memset(d,0,sizeof(d));
        memset(pl,0,sizeof(pl));
        memset(isv,0,sizeof(isv));
        memset(sum,0,sizeof(sum));
        for(int i=1;i<=n;i++){
            read(d[i]);read(v0[i]);read(a[i]);
        }
        for(int i=1;i<=m;i++)read(pl[i]),sum[pl[i]]++;
        for(int i=1;i<=L;i++)sum[i]+=sum[i-1];
        for(int i=1;i<=n;i++){
            if(a[i]==0||a[i]>0&&v0[i]>V){
                if(v0[i]<=V){
                    continue;
                }//all not
                if(v0[i]>V){
                    if(sum[L]-sum[d[i]-1]!=0){//all not
                        isv[i]=1;
                        add(d[i],1);add(L+1,-1);
                    }
                }//all
            }
            else if(a[i]>0){
                if((V*V-v0[i]*v0[i])/(2*a[i])+1>L-d[i]){
                    continue;
                }//all not
                int dis=(V*V-v0[i]*v0[i])/(2*a[i])+d[i]+1;
                if(sum[L]-sum[dis-1]==0){
                    continue;
                }//all not
                isv[i]=1;
                add(dis,1);
                add(L+1,-1);// dis to L
            }
            else if(a[i]<0){
                a[i]=0-a[i];
                if(v0[i]<=V){
                    continue;
                }//all not
                int dis2=(v0[i]*v0[i]-V*V)/(2*a[i])+d[i];
                if(dis2>=L){
                    if(sum[L]-sum[d[i]-1]==0)continue;//all not
                    isv[i]=1;
                    add(d[i],1);
                    add(L+1,-1);
                }//all
                else{
                    if(sum[dis2]-sum[d[i]-1]==0)continue;//all not
                    isv[i]=1;
                    add(d[i],1);add(dis2+1,-1);
                }//d to dis
            }

        }
        int num=0;
        //for(int i=1;i<=L;i++)cout<<sum[i]<<" ";
        //cout<<endl;
        for(int i=1;i<=n;i++)if(isv[i])num++/*,cout<<i<<" "*/;
        printf("%d ",num);
        int num2=0;
        int f=0;
        for(int i=1;i<=L;i++){
            if(sum[i]-sum[i-1]==0||f)continue;
            if(ask(i)==0)num2++/*,cout<<i<<endl*/;
            if(ask(i)==num)f=1;
        }
        if(f)printf("%d\n",m-1);
        //for(int i=1;i<=L;i++)c[i]+=c[i-1];
        //for(int i=1;i<=L;i++)cout<<ask(i)<<" ";
        if(!f)printf("%d\n",num2);
    }
    return 0;
}

/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/

// 2024.10.26
// fighting a losing battle
// but not regret choosing OI
// and say goodbye to ......
//RP+=INF
// and to y:we have met again.
